package com.muchfish.reactor.api;

import reactor.core.publisher.Flux;

public class ReactorErrorHandlingExample {
    public static void main(String[] args) {
        Flux<Integer> source = Flux.just(1, 2, 0, 4, 5);

        // 处理除零异常并提供默认值
        Flux<Integer> result = source.map(x -> 10 / x)
                .onErrorResume(ex -> Flux.just(-1));

        result.subscribe(System.out::println); // 输出: 10, 5, -1
    }
}

